﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Entity;

namespace Movies.Web.Models
{
    public class SeedDatabase  : DropCreateDatabaseAlways<MoviesDb>
    {
        protected override void Seed(MoviesDb context)
        {
            //this.GetActors().ForEach(b => context.Actors.Add(b));
            this.GetActors().ForEach(a => context.Actors.Add(a));
            this.GetDirectors().ForEach(d => context.Directors.Add(d));
            this.GetMovies().ForEach(m => context.Movies.Add(m));

            base.Seed(context);
        }

        protected List<Movie> GetMovies()
        {
            List<Movie> movies = new List<Movie>();

            movies.Add(new Movie() { Id=1, Name = "Ghost Busters", DirectedBy = new Director()  { FirstName = "Robert", LastName="Zemmekis" }, Rating="R", RelaseDate=DateTime.Parse("9/1/1983") });
            movies[0].Actors.Add(new Actor() { FirstName = "Bill", LastName = "Murray" });
            movies[0].DirectedBy.MoviesDirected.Add(movies[0]);


            return movies;
        }


        protected List<Actor> GetActors()
        {
            List<Actor> actors = new List<Actor>();

            actors.Add(new Actor() { Id=1, FirstName = "Faye", LastName = "Dunaway" });
            actors.Add(new Actor() { Id=2, FirstName = "Dan", LastName = "Akroyd" });

            return actors;
        }

        protected List<Director> GetDirectors()
        {
            List<Director> directors = new List<Director>();

            directors.Add(new Director() { Id=1, FirstName = "Steven", LastName = "Speilbergo" });
            directors.Add(new Director() { Id=2, FirstName = "Robert", LastName = "Zemekis" });
            return directors;
        }

    }

}